import request from '@/utils/request';

/**
 * 分页查询附加费维护
 */
export async function pageMaintainFeeAttachs(params) {
  const res = await request.get('/order/maintainFeeAttach/page', { params });
  if (res.data.code === 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 查询附加费维护列表
 */
export async function listMaintainFeeAttachs(params) {
  const res = await request.get('/order/maintainFeeAttach', {
    params
  });
  if (res.data.code === 0 && res.data.data) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 返回附加费维护select列表
 */
export async function listMaintainFeeAttachsSel(params) {
  const res = await request.get('/order/maintainFeeAttach/listSel', { params });
  if (res.data.code === 0 && res.data.data) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 根据id查询附加费维护
 */
export async function getMaintainFeeAttach(id) {
  const res = await request.get('/order/maintainFeeAttach/' + id);
  if (res.data.code === 0 && res.data.data) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 添加附加费维护
 */
export async function addMaintainFeeAttach(data) {
  const res = await request.post('/order/maintainFeeAttach', data);
  if (res.data.code === 0) {
    return res.data.message;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 修改附加费维护
 */
export async function updateMaintainFeeAttach(data) {
  const res = await request.put('/order/maintainFeeAttach', data);
  if (res.data.code === 0) {
    return res.data.message;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 删除附加费维护
 */
export async function removeMaintainFeeAttach(id) {
  const res = await request.delete('/order/maintainFeeAttach/' + id);
  if (res.data.code === 0) {
    return res.data.message;
  }
  return Promise.reject(new Error(res.data.message));
}
